from aiogram import Bot, Dispatcher, types, F, BaseMiddleware
from aiogram.fsm.context import FSMContext
from dotenv import load_dotenv
import os
import asyncio
import logging
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, ReplyKeyboardRemove, Message, ContentType, \
    TelegramObject, BotCommand
from icecream import ic

from handlers import home_bot
from utilites.queu_long import queue

load_dotenv()

bot_token = os.getenv('TOKEN')
bot = Bot(token=bot_token, parse_mode='HTML')


async def main():
    queue.start_worker(num_workers=2)
    logging.basicConfig(level=logging.INFO)
    dp = Dispatcher()
    dp.include_router(home_bot.router)

    await bot.send_message(453994951, 'Бот запущен', reply_markup=types.ReplyKeyboardRemove())
    await bot.delete_webhook(drop_pending_updates=True)
    await dp.start_polling(bot)
    await asyncio.sleep(5)
    await queue.stop_workers()


if __name__ == '__main__':
    asyncio.run(main())